package com.atguigu.hbase.mr.fruit.hbasetohbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;

/**
 * @ClassName FruitDriver
 * @DeScription FruitDriver
 * @Author 剧情再美终是戏
 * @Date 2019/12/9 10:04
 * @Version 1.0
 **/
public class FruitDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        // 获取conf
        Configuration conf = HBaseConfiguration.create();

        // 创建job
        Job job = Job.getInstance(conf);
        job.setJobName("job1");

        // 设置mapper
        TableMapReduceUtil.initTableMapperJob("fruit", new Scan(), FruitMapper.class, ImmutableBytesWritable.class, Put.class, job);

        // 设置reducer
        TableMapReduceUtil.initTableReducerJob("fruit_mr", FruitReducer.class, job);

        // 提交job
        job.waitForCompletion(true);
    }
}
